package com.jtcoding.chat.config;

import lombok.Getter;
import lombok.ToString;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.Properties;

/**
 * @Author jason.tang
 * @Date 2019/02/2 10:08
 * @Desc FastDFS配置类
 */
@Getter
@ToString
@Component
public class FastDFSProperties {
    @Value("${fastdfs.connectTimeout}")
    private String connectTimeout;

    @Value("${fastdfs.networkTimeout}")
    private String networkTimeout;

    @Value("${fastdfs.charset}")
    private String charset;

    @Value("${fastdfs.trackerHttpPort}")
    private String trackerHttpPort;

    @Value("${fastdfs.antiStealToken}")
    private String antiStealToken;

    @Value("${fastdfs.secretKey}")
    private String secretKey;

    @Value("${fastdfs.trackerServer}")
    private String trackerServer;

    public Properties generateProperties() {
        Properties properties = new Properties();

        properties.setProperty("fastdfs.tracker_servers", trackerServer);
        properties.setProperty("fastdfs.connect_timeout_in_seconds", connectTimeout);
        properties.setProperty("fastdfs.network_timeout_in_seconds", networkTimeout);
        properties.setProperty("fastdfs.charset", charset);
        properties.setProperty("fastdfs.http_anti_steal_token", antiStealToken);
        properties.setProperty("fastdfs.http_secret_key", secretKey);
        properties.setProperty("fastdfs.http_tracker_http_port", trackerHttpPort);

        return properties;
    }
}
